﻿using System;

namespace Lesson22_练习题
{
    #region 练习一
    //有一个玩家类 有姓名、血量、攻击力、防御力、闪避率等特征
    //请在控制台打印出“玩家XX，血量XX，攻击力XX，防御力XX，闪避率XX”
    class Player
    {
        private string name;
        private float Hp;
        private float Atk;
        private float Def;
        private float DodgeRate;
        public Player(string name, float hp, float atk, float def, float dodgeRate)
        {
            this.name = name;
            Hp = hp;
            Atk = atk;
            Def = def;
            DodgeRate = dodgeRate;
        }
        public override string ToString()
        {
            return $"玩家：{name}\n血量：{Hp}\n攻击力：{Atk}\n防御力：{Def}\n闪避率：{DodgeRate * 100}%";
        }
    }
    #endregion

    #region 练习二
    //一个Monster类的引用对象A Monster类有攻击力 防御力 血量 技能ID等属性
    //要复制一个和A对象一模一样的B对象 并且改变了B的属性 A不会受影响 该如何实现
    class Monster
    {
        public float Atk { get; set; }
        public float Def { get; set; }
        public float Hp { get; set; }
        public int SkillID { get; set; }
        public Monster(float atk, float def, float hp, int skillID)
        {
            Atk = atk;
            Def = def;
            Hp = hp;
            SkillID = skillID;
        }
        public Monster Clone()
        {
            return MemberwiseClone() as Monster;
        }
    }
    #endregion
    class Program
    {
        static void Main(string[] args)
        {
            #region 练习一
            Player p = new Player("LiberTy", 100, 20, 50, 0.1f);
            Console.WriteLine(p.ToString());
            #endregion

            #region 练习二
            Monster m = new Monster(20, 50, 100, 1);
            Monster m2 = m.Clone();
            m2.Atk = 25;
            Console.WriteLine(m2.Atk);
            Console.WriteLine(m.Atk);
            #endregion
        }
    }
}